package com.eedi.framework.social.dal.mapper;

import com.eedi.framework.common.enums.UserTypeEnum;
import com.eedi.framework.common.pojo.PageResult;
import com.eedi.framework.mybatis.core.mapper.BaseMapperX;
import com.eedi.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.eedi.framework.social.controller.sys.vo.client.SysSocialClientPageReq;
import com.eedi.framework.social.dal.dataobject.SysSocialClientDO;
import com.eedi.framework.social.enmus.SysSocialTypeEnum;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface SysSocialClientMapper extends BaseMapperX<SysSocialClientDO> {

    default SysSocialClientDO selectBySocialTypeAndUserType(SysSocialTypeEnum socialType, UserTypeEnum userType) {
        return selectOne(SysSocialClientDO::getSysSocialType, socialType,
                SysSocialClientDO::getSysSocialClientUserType, userType);
    }

    default PageResult<SysSocialClientDO> selectPage(SysSocialClientPageReq reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SysSocialClientDO>()
                .likeIfPresent(SysSocialClientDO::getSysSocialClientName, reqVO.getSysSocialClientName())
                .eqIfPresent(SysSocialClientDO::getSysSocialType, reqVO.getSysSocialType())
                .eqIfPresent(SysSocialClientDO::getSysSocialClientUserType, reqVO.getUserType())
                .likeIfPresent(SysSocialClientDO::getClientId, reqVO.getClientId())
                .eqIfPresent(SysSocialClientDO::getSysSocialClientStatus, reqVO.getSysSocialClientStatus())
                .orderByDesc(SysSocialClientDO::getId));
    }

}
